<template>
	<div class="content">
		<div class="input size">
			<el-row class="demo-autocomplete">
				<el-col :span="5" class="inpt_in">
					<el-form class="demo-form-inline">
						<el-form-item label="支付渠道" :label-width="formLabelWidth">
							<el-select v-model="ids" placeholder="下拉选择">
								<el-option v-for="item in zfopnet" :key="item.id" :label="item.payName" :value="item.id">
								</el-option>
							</el-select>
						</el-form-item>
					</el-form>
				</el-col>
				<el-col :span="2" class="inpt_in">
					<el-button style="width: 5vw;" type="primary" @click="PaymentSearch">切换</el-button>
				</el-col>
			</el-row>
		</div>
		<div class="boder">
			<el-row class="demo-autocomplete">
				<el-col :span="5" class="inpt_in">
					<el-form class="demo-form-inline">
						<el-form-item label="微信支付" :label-width="formLabelWidth">
							<el-radio v-model="update.wxpayType" label="1">启用</el-radio>
							<el-radio v-model="update.wxpayType" label="0">禁用</el-radio>
						</el-form-item>
					</el-form>
				</el-col>
			</el-row>
			<el-row class="demo-autocomplete">
				<el-col :span="5" class="inpt_in">
					<el-form class="demo-form-inline">
						<el-form-item label="支付宝支付" :label-width="formLabelWidth">
							<el-radio v-model="update.alipayType" label="1">启用</el-radio>
							<el-radio v-model="update.alipayType" label="0">禁用</el-radio>
						</el-form-item>
					</el-form>
				</el-col>
			</el-row>
			<el-row :span="16" class="row-bg" style="margin-top: 2vh;">
				<el-col :span="5">
					<el-form class="demo-form-inline">
						<el-form-item label="微信支付费率" :label-width="formLabelWidth">
							<el-input autocomplete="off" v-model="update.wxpayRate"></el-input>
						</el-form-item>
					</el-form>
				</el-col>
			</el-row>
			<el-row :span="16" class="row-bg" style="margin-top: 2vh;">
				<el-col :span="5">
					<el-form class="demo-form-inline">
						<el-form-item label="支付宝支付费率" :label-width="formLabelWidth">
							<el-input autocomplete="off" v-model="update.alipayRate"></el-input>
						</el-form-item>
					</el-form>
				</el-col>
			</el-row>
			<el-row :span="16" class="row-bg" style="margin-top: 2vh;">
				<el-col :span="2" class="inpt_in">
					<!-- <el-button style="width: 5vw;" type="primary" @click="PaymentSearch">确定</el-button> -->
				</el-col>
				<el-col :span="2" class="inpt_in">
					<!-- <el-button style="width: 5vw;" type="primary" @click="PaymentSearch">确定</el-button> -->
				</el-col>
				<!-- <el-col :span="2" class="inpt_in">
					<el-button style="width: 5vw;" type="primary" @click="PaymentSearch">修改</el-button>
				</el-col> -->
			</el-row>
			<el-row :span="16" class="row-bg" style="margin-top: 2vh;">
				<el-col :span="2" class="inpt_in">
				</el-col>
				<el-col :span="2" class="inpt_in">
				</el-col>
				<el-col :span="2" class="inpt_in">
					<el-button style="width: 5vw;" type="primary" @click="updent">修改</el-button>
				</el-col>
			</el-row>
		</div>
	</div>
	</div>
</template>
<script>
	import api from '../../../api/PurchaseDelivery/index.js'
	export default {
		data() {
			return {
				formLabelWidth: '6vw',
				zfopnet: [],
				update: {
					// "id": "",
					// "wxpayType": "1",
					// "wxpayRateStr": "72%",
					// "alipayType": "0",
					// "alipayRateStr": "68%"
				},
				gxupdata: {
					"id": 1,
					"wxpayType": 1,
					"wxpayRateStr": "72%",
					"alipayType": 1,
					"alipayRateStr": "68%"
				},
				ids: ''
			}
		},
		created() {
			this.$axios.post(`${api}/gamemall/paySetting/getList`, {
					"state": 1
				})
				.then(res => {
					this.zfopnet = res.data
				})
				.catch(err => {
					// this.$message({
					// 	message: '请求异常',
					// 	type: 'warning'
					// })
				});
		},
		methods: {
			buildUpdateParam() {},
			PaymentSearch() {
				console.log(this.ids)
				this.$axios.post(`${api}/gamemall/paySetting/getPaySettingById`, {
						"state": 1,
						"id": this.ids
					})
					.then(res => {
						if (res.code == 200) {
							console.log(res.data[0])
							this.update = res.data[0]
							console.log(res.data.wxpayType)
							this.update.wxpayType = "" + this.update.wxpayType + ""
							console.log(this.update)
							this.update.alipayType = "" + this.update.alipayType + ""
							this.$message({
								message: '切换成功',
								type: 'warning'
							})
						}
					})
					.catch(err => {
						// this.$message({
						// 	message: '请求异常',
						// 	type: 'warning'
						// })
					});
			},
			updent() {
				this.$axios.post(`${api}/gamemall/paySetting/update`,this.update)
					.then(res => {
						if (res.code == 200) {
							this.$message({
								message: '修改成功',
								type: 'warning'
							})
						}
						if (res.code == 500) {
							this.$message({
								message: '修改失败',
								type: 'warning'
							})
						}
					})
					.catch(err => {
						// this.$message({
						// 	message: '请求异常',
						// 	type: 'warning'
						// })
					});
			}
		}
	}
</script>

<style scoped>
	.content {
		width: 99%;
		height: 99%;
		margin-left: 0.5%;
		border: 1px solid #EBEEF5;
		background-color: #FFF;
		border-radius: 0.325rem;
	}

	.inpt_in {
		margin-top: 3%;
	}

	.boder {
		width: 98%;
		height: 75%;
		border: 1px solid #EBEEF5;
		margin-top: 2%;
		margin-left: 1%;
	}

	.size {
		font-size: 0.8rem;
		color: #606266;
	}
</style>
